package com.kissoft.common.util;

import org.apache.log4j.Logger;

public class KisLogger {
	
    private static KisLogger singleton = null;
    public KisLogger(){}
    public static KisLogger getInstance(){
		if(singleton == null) singleton = new KisLogger();
        return singleton;
	}
    
	public static class LoggerCode {
		public static int DEBUG = 1;
		public static int INFO = 2;
		public static int ERROR = 9;
	}
	
	private Logger dLogger = Logger.getLogger("DEBUG");
	private Logger iLogger = Logger.getLogger("INFO");
	private Logger eLogger = Logger.getLogger("ERROR");
	
	private String logId;
	private String logMenu;
	private String logAction;
	
	public void setLogId(String id) {
		this.logId = id;
	}
	
	public void setLogMenu(String menu) {
		this.logMenu = menu;
	}
	
	public void setLogAction(String action) {
		this.logAction = action;
	}
	public void logWrite(int loggerType, Exception ex) {
		String errString = "Exception :"+ex.getMessage();
		dLogger.info(errString);
		iLogger.debug(errString);
		eLogger.error(errString, ex);
	}
	
	public void logWrite(int loggerType, String desc) {
		String log = "[" + logId + "][" + logMenu + "][" + logAction + "] : " + desc;
		switch(loggerType) {
		case 1:
			dLogger.debug(log);
			break;
		case 2:
			iLogger.info(log);
			break;
		case 9:
			eLogger.error(log);
			break;
		}
	}
}
